package br.com.dreamsource.mobile.worders.forms.core;

import br.com.dreamsource.mobile.worders.WOrders;
import br.com.dreamsource.mobile.components.FormWOrders;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;

/**
 *
 * @author Elizeu Nogueira da Rosa Jr;
 * @version 0.1
 * @date 21.05.2007 
 *
 */

public class SystemMessage extends FormWOrders {
    
    private StringItem siError;
    private String errorMessage;
    private Form backForm;
    private String title;
    
    public SystemMessage(CommandListener listener, WOrders midlet, String title, String errorMessage, Form backForm) {
        super(listener, midlet, title);
        this.title = title;
        this.errorMessage = errorMessage;
        this.backForm = backForm;
        this.createComponents2();
    }
    
    private StringItem getSiError() {
        if (siError == null) {
            siError = new StringItem(this.title, errorMessage);
        }
        return siError;
    }
    
    private void createComponents2() {
        this.append(this.getSiError());
        this.addCommand(this.getBackCommand());
    }

    protected void createComponents() {
    }
    
    public void fireCommand(javax.microedition.lcdui.Command command) {
        if (command == this.backCommand) {
            if (this.backForm == null) {
                this.midlet.closeApp();
            }
            this.sendToForm(this.backForm);
            this.midlet.destroyForm(this);
        }
    }
    
}
